﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace PInvokeTest
{
    public enum Job
    {
        teacher,
        worker
    }
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
    public class Person
    {
        //[MarshalAs(UnmanagedType.U4)]
        public double age;
        public Job job;
        public void Eat()
        {
            IntPtr value = UnsafenativeMethod.CreatePerson();
            UnsafenativeMethod.PersonEat(value);

            Console.WriteLine("s");
            Console.ReadLine();
        }
    }
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
    public struct Student 
    {
        public double age;
        public Job job;
        public int grade;
    }
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
    public class Teacher : Person
    {
        public IntPtr student;
        public int sd;
        public static void Call(Teacher teacher)
        {
            UnsafenativeMethod.SetTeacher(teacher);
        }
    }
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
    public class PureTeacher
    {
        public double age;
        public Job job;
        public Student student;
        public int sd;
        public static void Call(PureTeacher teacher)
        {
            UnsafenativeMethod.SetTeacher(teacher);
        }
    }
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
    public class TeacherP
    {
        public double age;
        public Job job;
        public IntPtr student;
        public int sd;
        public static void Call(TeacherP teacher)
        {
            UnsafenativeMethod.SetTeacherP(teacher);
        }
    }
}
